package study.sso.jwt.controller;

import cn.hutool.core.map.MapUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.eggs.result.Result;
import study.eggs.result.Results;
import study.sso.jwt.service.LoginService;

@Slf4j
@RestController
public class LoginController {

    @Autowired
    private LoginService loginService;

    @RequestMapping("/login")
    public Result login() {
        String jwt = loginService.login();
        return Results.ok(MapUtil.of("jwt", jwt));
    }

    @RequestMapping("/logout")
    public Result logout(@RequestHeader("X-Token") String token) {
        return Results.ok();
    }
}
